/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

// 网点公众号管理

import request from '@/utils/request';
import { message } from 'antd';
import { isArray } from 'lodash';

export async function getAccountsList(params: any): Promise<any> {
  return request('/shopOpen/ajax', {
    method: 'POST',
    data: params,
  }).then((res) => {
    const { action } = params;
    const { list, count, page } = res.data || {};
    if (res.code == 0) {
      if (isArray(list) && list.length > 0) {
        return {
          total: count,
          success: true,
          data: list,
          page,
        };
      }
      if (
        action === 'authInfo' ||
        action === 'authOfficialAccountsGet' ||
        action === 'addManager' ||
        action === 'wtMenuLink'
      ) {
        return list || res.data;
      }
    }
    message.error(res.msg);
    return {};
  });
}

export async function tmpUpdata(params: any): Promise<any> {
  return request('/PushRemark/updateRemark', {
    method: 'POST',
    data: params,
  });
}
